<!--
 * @FilePath     : /study_code/vue2.x/component.sync2.html
 * @Description  : 修改父组件复杂类型数据
 * @Date         : 2025-05-02 17:38:26
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-02 17:38:37
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app">
      <div>父组件数据2： {{ doc.name }} --- {{ doc.age }}</div>
      <p>子组件</p>

      <my-component v-bind:doc.sync="doc"></my-component>
    </div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      Vue.component('my-component', {
        prop: {
          doc: {
            type: Object,
          },
        },
        template: `
      <button v-on:click="updateCount">修改父组件数据</button>
      `,
        methods: {
          updateCount() {
            this.$emit('update:doc', {
              name: 'ls',
              age: 28,
            })
          },
        },
      })

      var vm = new Vue({
        el: '#app',
        data: function () {
          return {
            doc: {
              name: 'zs',
              age: 18,
            },
          }
        },
      })
    </script>
  </body>
</html>
